<?php
class m_order_beli extends CI_Model {

    function __construct() {
        parent::__construct();
    }

    public function get($where = null, $limit = null, $offset = null)
    {
        if($where != null) $this->db->where($where);
        if($limit != null && $offset != null) $this->db->limit($limit, $offset);
        return $this->db->get("order_beli");
    }
	
    function get_all($limit, $uri) {

        $result = $this->db->get('order_beli', $limit, $uri);
        if ($result->num_rows() > 0) {
            return $result->result_array();
        } else {
            return array();
        }
    }

    function get_one($id) {
        $this->db->where('NOMER_ORDER', $id);
        $result = $this->db->get('order_beli');
        if ($result->num_rows() == 1) {
            return $result;
        } else {
            return array();
        }
    }

    function insert() {
           $data = array(
        
            'ID_SUPPLIER' => $this->input->post('ID_SUPPLIER', TRUE),
           
            'NAMA_SUPPLIER' => $this->input->post('NAMA_SUPPLIER', TRUE),
           
            'TGL_ORDER' => $this->input->post('TGL_ORDER', TRUE),
           
        );
        return $this->db->insert('order_beli', $data);
    }

    function update($id) {
        $data = array(
         
       'ID_SUPPLIER' => $this->input->post('ID_SUPPLIER', TRUE),
       
       'NAMA_SUPPLIER' => $this->input->post('NAMA_SUPPLIER', TRUE),
       
       'TGL_ORDER' => $this->input->post('TGL_ORDER', TRUE),
       
        );
        $this->db->where('NOMER_ORDER', $id);
        return $this->db->update('order_beli', $data);
    }

    function delete($id) {
		$this->db->where('NOMER_ORDER', $id);
        $this->db->delete('order_beli');
    }

}
?>
